package src.edu.wayne.cs.csc4110.hw6.interfaces;


import java.util.ArrayList;
import java.util.HashSet;

import javax.swing.JPanel;

public interface FrameWork {
	
	/**
	 * Call this method to startup the framework.
	 * If a dummy database is being loaded, then it
	 * needs to be loaded before calling this method. 
	 */
	public abstract void startFrameWork();

	/**
	 * The framework has a single session running at any given time.
	 * All users that are logged in belong to this session.
	 * Add any user that logs in to the session by using this method.
	 * @param user
	 */
	public abstract void addUserToSession(User user);
	
	/**
	 * Allows the caller to point the framework to an externally
	 * instantiated database.
	 * @param dataBase
	 */
	public abstract void setDataBase(FacelookDatabase dataBase);
	
	/**
	 * gets the database the the framework holds a reference to.
	 * This is useful for calling the dbase methods.
	 * @return FacelookDatabase
	 */
	public abstract FacelookDatabase getDataBase();
	
	/**
	 * The framework holds a single reference to the plugin that
	 * is currently being used (can sometimes be null).
	 * 
	 * @return Game
	 */
	public abstract Game getPlugin();

	/**
	 * sets the frameworks single reference to a plugin of type
	 * Game.
	 * @param plugin
	 */
	public abstract void setPlugin(Game plugin);

	/**
	 * Gets the hashset<User> of users that are in session.
	 * Note:  there are plans to deprecate this method, and
	 * add one that returns an ArrayList<User> instead.
	 * @return HashSet<User>
	 */
	public abstract HashSet<User> getUsersInSession();

	/**
	 * Allows the framework user to add a HashSet<User> rather than
	 * adding users to the current session one at a time.
	 * Note: this will replace the reference to the current HashSet<User>
	 * thereby sending it to the trash collection.
	 * @param usersInSession
	 */
	public abstract void setUsersInSession(HashSet<User> usersInSession);
	
	/**
	 * Checks the user.emailAddess against all of the users in session.
	 * @param user
	 * @return true if a match is found.
	 */
	public abstract boolean isUserInCurrentSession(User user);
	
	/**
	 * Removes the User from the framework session list.
	 * @param user
	 */
	public abstract void removeUserFromSession(User user);
	
	/**
	 * Returns all of the games that are in the ArrayList held by the framework.
	 * @return
	 */
	public ArrayList<Game> getGameList();

	/**
	 * Replaces the current display panel with the one referred to by
	 * newPanel.
	 * 
	 * Sets the title of the window to newTitle.
	 * @param newPanel (type JPanel)
	 * @param newTitle (type String)
	 */
	public void setCurrentPanel(JPanel newPanel, String newTitle);

	/**
	 * Checks the email and password given as arguments to see if they
	 * are a valid pair.  This is done by delegation to the FacelookDatabase.
	 * Returns true if the pair are a valid match.
	 * @param email
	 * @param pwd
	 * @return boolean: returns true if the pair match the ones stored in the dbase.
	 */
	public boolean login(String email, String pwd);
	
}
